#ifndef _TEST_FUNCTION_H_
#define _TEST_FUNCTION_H_

#include <iostream>
#include <map>
#include <string>
#include "TestHeader.h"
#include "TestException.h"

class TestCase;


class TestFunction
{
    public:
        virtual int run(TestCase *tc)  = 0;
        virtual ~TestFunction() {};
};


template <typename C>
class TestFunctionT : public TestFunction
{
    private:
        typedef int (C::*testFunType)();

    public:
        TestFunctionT(testFunType tf): _testFun(tf) {}
        virtual ~TestFunctionT() {};

        int run(TestCase *tc)
        {
            C *testCase = dynamic_cast<C*>(tc);
            if (testCase == NULL)
            {
                throw ErrorException("TestFunctionT::run");
                return -1;
            }
            return (testCase->*_testFun)();
        } 

    private:
        testFunType _testFun;
};



#endif
